﻿Imports TMySQL
Public Class frmTableStatus
    Private _Table As IHasColumns
    Private Enum TRowV As Integer
        coTableCatalog = 0
        coTableSchema = 1
        coTableName = 2
        coCheckOption = 3
        coIsUpdatable = 4
        coDefiner = 5
        coSecurityType = 6
        coCharacterSetClient = 7
        coCollationConnection = 8
    End Enum
    Private Enum TRow As Integer
        coName = 1
        coEngine = 2
        coVersion = 3
        coRow_format = 4
        coRows = 5
        coAvgRowLength = 6
        coDataLength = 7
        coMaxDataLength = 8
        coIndexLength = 9
        coDataFree = 10
        coAutoIncrement = 11
        coCreateTime = 12
        coUpdateTime = 13
        coCheckTime = 14
        coCollation = 15
        coChecksum = 16
        coCreateOptions = 17
        coComment = 18
    End Enum
    Public Sub New(ByVal ATable As IHasColumns)
        Me.New()
        _Table = ATable
        InitFrm()
    End Sub
    Private Sub New()
        ' この呼び出しは、Windows フォーム デザイナで必要です。
        InitializeComponent()
        ' InitializeComponent() 呼び出しの後で初期化を追加します。
    End Sub
    Private Sub InitFrm()
        frmMain.GeneralSettings.ApplyAll(Me)
        frmMain.GridSettings.ApplyAll(Me)
        InitTab()
        Select Case _Table.GetType.ToString
            Case "TMySQL.TMyTable"
                ShowTableStatus(_Table)
            Case "TMySQL.TMySystemView"
                ShowSystemViewStatus(_Table)
            Case "TMySQL.TMyView"
                ShowViewStatus(_Table)
        End Select
    End Sub
    Private Sub InitTab()
        Grid.Columns.Clear()
        Dim col As New DataGridViewTextBoxColumn
        col.HeaderText = "Name"
        col.ReadOnly = True
        col.Width = 100
        Grid.Columns.Add(col)

        col = New DataGridViewTextBoxColumn
        col.HeaderText = "Value"
        col.ReadOnly = True
        col.Width = 100
        Grid.Columns.Add(col)
    End Sub

    Private Sub ShowSystemViewStatus(ByVal ASystemView As TMySystemView)
        Grid.Rows.Clear()
        Grid.Rows.Add("Name", ASystemView.TableName)
        Grid.Rows.Add("Engine", ASystemView.Engine)
        Grid.Rows.Add("Version", ASystemView.Version)
        Grid.Rows.Add("Row_format", ASystemView.RowFormat)
        Grid.Rows.Add("Rows", ASystemView.TableRows)
        Grid.Rows.Add("Avg_row_length", ASystemView.AvgRowLength)
        Grid.Rows.Add("Data_length", ASystemView.DataLength)
        Grid.Rows.Add("Max_data_length", ASystemView.MaxDataLength)
        Grid.Rows.Add("Index_length", ASystemView.IndexLength)
        Grid.Rows.Add("Data_free", ASystemView.DataFree)
        Grid.Rows.Add("Auto_increment", ASystemView.AutoIncrement)
        Grid.Rows.Add("Create_time", ASystemView.CreateTime)
        Grid.Rows.Add("Update_time", ASystemView.UpdateTime)
        Grid.Rows.Add("Check_time", ASystemView.CheckTime)
        Grid.Rows.Add("Collation", ASystemView.TableCollation)
        Grid.Rows.Add("Checksum", ASystemView.Checksum)
        Grid.Rows.Add("Create_options", ASystemView.CreateOptions)
        Grid.Rows.Add("Comment", ASystemView.TableComment)

    End Sub
    Private Sub ShowTableStatus(ByVal ATable As TMyTable)
        Grid.Rows.Clear()
        Grid.Rows.Add("Name", ATable.TableName)
        Grid.Rows.Add("Engine", ATable.Engine)
        Grid.Rows.Add("Version", ATable.Version)
        Grid.Rows.Add("Row_format", ATable.RowFormat)
        Grid.Rows.Add("Rows", ATable.TableRows)
        Grid.Rows.Add("Avg_row_length", ATable.AvgRowLength)
        Grid.Rows.Add("Data_length", ATable.DataLength)
        Grid.Rows.Add("Max_data_length", ATable.MaxDataLength)
        Grid.Rows.Add("Index_length", ATable.IndexLength)
        Grid.Rows.Add("Data_free", ATable.DataFree)
        Grid.Rows.Add("Auto_increment", ATable.AutoIncrement)
        Grid.Rows.Add("Create_time", ATable.CreateTime)
        Grid.Rows.Add("Update_time", ATable.UpdateTime)
        Grid.Rows.Add("Check_time", ATable.CheckTime)
        Grid.Rows.Add("Collation", ATable.TableCollation)
        Grid.Rows.Add("Checksum", ATable.Checksum)
        Grid.Rows.Add("Create_options", ATable.CreateOptions)
        Grid.Rows.Add("Comment", ATable.TableComment)
    End Sub
    Private Sub ShowViewStatus(ByVal AView As TMyView)
        Grid.Rows.Clear()
        Grid.Rows.Add("Table_catalog", AView.TableCatalog)
        Grid.Rows.Add("Table_schema", AView.TableSchema)
        Grid.Rows.Add("Table_name", AView.TableName)
        Grid.Rows.Add("Check_option", AView.CheckOption)
        Grid.Rows.Add("Is_updatable", AView.IsUpdatable)
        Grid.Rows.Add("Definer", AView.Definer)
        Grid.Rows.Add("Security_type", AView.SecurityType)
        Grid.Rows.Add("Character_set_client", AView.CharacterSetClient)
        Grid.Rows.Add("Collation_connection", AView.CollationConnection)
    End Sub

    Public Sub ApplyControlFontSettings(ByVal AControl As Control, ByVal ASettings As TGeneralSettings)
        For Each ctrl As Control In Me.Controls
            If ctrl.Controls.Count > 0 Then
                ApplyControlFontSettings(ctrl, ASettings)
            End If
            If Not ctrl.GetType Is GetType(Sgry.Azuki.WinForms.AzukiControl) Then
                ctrl.Font = ASettings.Font
                ctrl.BackColor = ASettings.BackColor
                ctrl.ForeColor = ASettings.ForeColor
            End If
        Next
    End Sub

End Class